//
//  FileDetailViewController.swift
//  GitOSC-Swift
//
//  Created by 李萍 on 16/3/10.
//  Copyright © 2016年 李萍. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

class FileDetailViewController: UIViewController {
    var nameSpace: String!
    var currentPath: String!
    var files: GTFiles!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.lightGrayColor()

//        self.fetchFileDetail()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    //获取数据
    func fetchFileDetail() {
        let userinfos = UserInfos()
        let private_token = userinfos.getprivateToken()
        
        let parameters = "file_path=\(currentPath)&private_token=\(private_token)"
        
        let strUrl = "https://git.oschina.net/api/v3/projects/\(nameSpace)/repository/tree?\(parameters)"
        
        Alamofire.Manager.sharedInstance.request(Method.GET, strUrl).responseJSON { response in
            if let results = response.result.value {
                let jsonArray = JSON(results)
                
                print(jsonArray)
            }
        }
    }
}
